<template>
	<view class="mine-container" :style="{height: `${windowHeight}px`}">
		<!--顶部个人信息栏-->
		<view class="header-section">
			<view class="flex padding justify-between">
				<view class="flex align-center" style="width:100%">
					<view v-if="!avatar" class="cu-avatar xl round bg-white">
						<view class="iconfont icon-people text-gray icon"></view>
					</view>
					<image v-if="avatar" @click="handleToAvatar" :src="avatar" class="cu-avatar xl round"
						mode="widthFix">
					</image>
					<view v-if="!name" @click="handleToLogin" class="login-tip">
						<view class="noLogin">未登录</view>
						<view class="noLoginText">登录查看个人信息</view>
					</view>
					<view v-if="name" class="user-info">
						<view class="left">
							<view class="u_title">
								{{ $desensitizationName(name) }}
							</view>
						</view>
						<view class="right" @click="showErcode">
							<img src="@/static/images/ewm.png"></img>
						</view>
					</view>
				</view>
				<view v-if="!name" @click="handleToLogin" class="loginBtnWrap flex align-center">
					<view class="loginBtn">去登录</view>
				</view>

			</view>
			<view class="btnsWrap flex align-center" v-if="name">
				<view class="addjkk flex align-center" @click.native="addHealth">
					<img src="@/static/images/tjjkk.svg" style="margin-right:10px;"></img>
					添加就诊卡
				</view>
				<view class="addjkk flex align-center" @click.native="goHealthList">
					<img src="@/static/images/dzjkk.svg" style="margin-right:10px;"></img>
					电子健康卡
				</view>
			</view>
		</view>

		<view class="content-section">
			<view class="mine-actions grid col-3 text-center">
				<view class="action-item" @click="handleJiaoLiuQun">
					<img src="@/static/images/我的预约.svg" class="svgIcon"></img>
					<text class="text">挂号记录</text>
				</view>
				<view class="action-item" @click="goReservation">
					<img src="@/static/images/我的报告.svg" class="svgIcon"></img>
					<text class="text">检查报告</text>
				</view>
				<view class="action-item" @click="goPaymentRecords">
					<img src="@/static/images/缴费记录.svg" class="svgIcon"></img>
					<text class="text">缴费记录</text>
				</view>
			</view>

			<view class="menu-list">
				<!-- <view class="list-cell list-cell-arrow" @click="handleToEditInfo">
          <view class="menu-item-box">
            <img src="@/static/images/wddb.svg" class="svgIcon"></img>
            <view>我的待办</view>
          </view>
        </view> -->
				<view class="list-cell list-cell-arrow" @click="handleHelp">
					<view class="menu-item-box">
						<img src="@/static/images/wddl.svg" class="svgIcon"></img>
						<view>我的队列</view>
					</view>
				</view>
				<view class="list-cell list-cell-arrow" @click="deleteStorageSync">
					<view class="menu-item-box">
						<img src="@/static/images/ssxx.svg" class="svgIcon"></img>
						<view>清除缓存</view>
					</view>
				</view>
				<!-- <view class="list-cell list-cell-arrow" @click="handleToSetting">
          <view class="menu-item-box">
            <img src="@/static/images/wdxx.svg" class="svgIcon"></img>
            <view>我的信息</view>
          </view>
        </view> -->
				<view class="list-cell list-cell-arrow" @click="handleToSetting">
					<view class="menu-item-box">
						<img src="@/static/images/tssz.svg" class="svgIcon"></img>
						<view>推送设置</view>
					</view>
				</view>
			</view>

		</view>
		<u-popup :show="showVisitErcode" :customStyle="{'width':'94%'}" :round="10" :safeAreaInsetBottom="true"
			mode="center" @close="closeErcode">
			<view class="top-bar flex align-center justify-end p-t-30 p-r-30">
				<img style="width: 34rpx;" src="@/static/images/homeIndex/close-ico.png" @click="closeErcode"></img>
			</view>
			<view class="ercode-pop flex flex-column align-center p-b-40">
				<!-- <img class="avatar" src="@/static/images/homeIndex/avator-doctor.png" alt=""> -->
				<u--image width="70" height="70" :src="currentVisitInfo.headImg" shape="circle"></u--image>
				<text
					class="color-323232 f-s-36 f-bold m-t-15 m-b-15">{{$desensitizationName(currentVisitInfo.name)}}</text>
				<text class="color-888 f-s-30"
					style="letter-spacing: 6rpx;">卡号：{{$desensitizationNormalStr(currentVisitInfo.cardNum)}}</text>
				<!-- <img class="ercode" :src="currentVisitInfo.qrCode"></img> -->
				<QrCode :id="'QrCode'" :width="260" :height="260" :codeUrl="currentVisitInfo.cardNum" />
				<text class="f-s-28" style="color: #FF7C4D;">温馨提示</text>
				<text class="f-s-28 m-t-15" style="text-align: center;">就诊时请出示就诊码就诊二维码是实时有效的，请不要使用截图就诊</text>
			</view>
		</u-popup>
	</view>
</template>

<script>
	import QrCode from '@/components/qrcode/index.vue';
	import storage from '@/utils/storage'
	import {
		getPatientBaseList
	} from '@/api/card/index.js'
	export default {
		components: {
			QrCode
		},
		data() {
			return {
				name: this.$store.state.user.name,
				version: getApp().globalData.config.appInfo.version,
				mrCardinfo: {},
				showVisitErcode: false,
				currentVisitInfo: {

				},
			}
		},
		computed: {
			avatar() {
				return this.$store.state.user.avatar
			},
			windowHeight() {
				return uni.getSystemInfoSync().windowHeight - 50
			}
		},
		created() {
			// this.getList()
		},
		methods: {
			goHealthList() {
				this.$tab.navigateTo('/pages/addHealthCard/cardList')
			},
			showErcode() {
				if (uni.getStorageSync('currentVisitCard') == '') {
					this.$tab.navigateTo('/pages/addHealthCard/index')
				} else {
					this.currentVisitInfo = JSON.parse(uni.getStorageSync('currentVisitCard'))
					this.showVisitErcode = true
				}
			},
			closeErcode() {
				this.showVisitErcode = false
			},
			deleteStorageSync() {
				uni.clearStorage()
				this.$modal.showToast('清除成功,请退出或手动刷新')
			},
			addHealth() {
				this.$tab.navigateTo('/pages/addHealthCard/index')
			},
			handleToInfo() {
				this.$tab.navigateTo('/pages/mine/info/index')
			},
			handleToEditInfo() {
				this.$tab.navigateTo('/pages/mine/info/edit')
			},
			handleToSetting() {
				this.$tab.navigateTo('/pages/mine/setting/index')
			},
			goPaymentRecords() {
				if (uni.getStorageSync('currentVisitCard') == '') {
					this.$tab.navigateTo('/pages/addHealthCard/index')
				} else {
					this.$tab.navigateTo('/pages/mine/paymentRecords/index')
				}
			},
			handleToLogin() {
				if (getApp().globalData.mediaType == 'zfb') { //支付宝

				} else { //微信
					this.$store.dispatch('WXLogin')
				}

			},
			handleToAvatar() {
				this.$tab.navigateTo('/pages/mine/avatar/index')
			},
			handleLogout() {
				this.$modal.confirm('确定注销并退出系统吗？').then(() => {
					this.$store.dispatch('LogOut').then(() => {
						this.$tab.reLaunch('/pages/index')
					})
				})
			},
			handleHelp() {
				this.$tab.navigateTo('/pages/lineUp/index')
			},
			handleAbout() {
				this.$tab.navigateTo('/pages/mine/about/index')
			},
			handleJiaoLiuQun() {
				if (uni.getStorageSync('currentVisitCard') == '') {
					this.$tab.navigateTo('/pages/addHealthCard/index')
				} else {
					this.$tab.navigateTo('/pages/mine/confirmRegistration/index')
				}
			},
			goReservation() {
				if (uni.getStorageSync('currentVisitCard') == '') {
					this.$tab.navigateTo('/pages/addHealthCard/index')
				} else {
					this.$tab.navigateTo('/pages/mine/report/index')
				}
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #f5f6f7;
	}



	.mine-container {
		// letter-spacing: 0.15rem;
		width: 100%;
		height: 100%;

		.ercode-pop {
			width: 70%;
			margin-left: 15%;

			.avatar {
				width: 160rpx;
			}

			.ercode {
				width: 100%;
			}
		}

		.header-section {
			padding: 40rpx;
			background-color: #3c96f3;
			color: white;
			background-image: url('@/static/images/bg.png');
			background-repeat: no-repeat;
			background-size: 100% 100%;

			.loginBtnWrap {
				.loginBtn {
					border-radius: 8rpx;
					font-size: 24rpx;
					padding: 3px 15px;
					border: 1px solid rgba(255, 255, 255, 1);
					white-space: nowrap;
				}
			}

			.login-tip {
				margin-left: 20rpx;

				.noLogin {
					font-size: 32rpx;
					margin-bottom: 8rpx;
				}

				.noLoginText {
					font-size: 28rpx;
					color: rgba(255, 255, 255, 0.6);
				}
			}

			.cu-avatar {
				width: 90rpx;
				height: 90rpx;
				border: 2px solid #eaeaea;

				.icon {
					font-size: 60rpx;
				}
			}

			.user-info {
				margin-left: 20rpx;
				display: flex;
				align-items: center;
				flex: 1;

				.left {
					flex: 1;

					.u_title {
						font-size: 36rpx;
						line-height: 60rpx;
					}
				}

				.right {
					width: 72rpx;
					height: 72rpx;

					img {
						width: 100%;
						height: 100%;
					}
				}
			}

			.btnsWrap {
				.addjkk {
					background: #DFEBFF;
					padding: 8rpx 20rpx;
					border-radius: 8rpx;
					color: #4D8EFF;
					margin-right: 30rpx;

					img {
						width: 36rpx;
						height: 36rpx;
					}
				}

			}
		}

		.content-section {
			.menu-list {
				margin: 24rpx;
				font-size: 32rpx;

				.list-cell {
					padding: 40rpx 30rpx;

					.svgIcon {
						width: 40rpx;
						height: 40rpx;
						margin-right: 10px;
					}
				}
			}

			.mine-actions {
				margin: 24rpx;
				padding: 40rpx 0px;
				border-radius: 8px;
				background-color: white;

				.action-item {
					.svgIcon {
						width: 64rpx;
						height: 64rpx;
					}

					.text {
						display: block;
						font-size: 32rpx;
						margin: 16rpx 0;
					}
				}
			}
		}
	}
</style>